package com.lyq.controller;

import com.lyq.mapper.UserMapper;
import com.lyq.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lyq
 * @since 2020-05-20
 */
@RestController
@RequestMapping("/weixing/user")
public class UserController {
    @Autowired
    private UserMapper userMapper;
            @RequestMapping(value = "/insertLoginUser")
    public Integer insertLonginUser(String name,String password){
        User user = new User();
        user.setName(name);
        user.setPassword(password);
                int insert = userMapper.insert(user);
                return insert;

            }
            @RequestMapping(value = "/Login", method = RequestMethod.POST)
            @ResponseBody
     public List<User> login(String name,String password){
                Map<String,Object> map = new HashMap<>();
                map.put("name",name);
                map.put("password",password);
                List<User> users = userMapper.selectByMap(map);
                return users;

            }
     }



